package org.example.basic.functionclass;

import java.util.Comparator;
import java.util.function.BinaryOperator;

/**
 * @author songyafei
 */
public class BinaryOperatorFunction {
    public static void main(String[] args) {
        //BinaryOperator<T>
        //代表了一个作用于于两个同类型操作符的操作，并且返回了操作符同类型的结果
        BinaryOperator<String> binaryOperator = (str1,str2)-> String.valueOf(str1.length()-str2.length());
        String apply = binaryOperator.apply("AC", "B");
        System.out.println(apply);

        BinaryOperator<Integer> integerBinaryOperator = (num1,num2)->num1 + num2;
        System.out.println(integerBinaryOperator.apply(3,99));

        Comparator<String> comparator = new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return 0;
            }
        };
        Object apply1 = BinaryOperator.maxBy(comparator).apply("Afff", "gfgfgf");
        System.out.println(apply1);
    }
}
